/**
 * Created by Administrator on 2017/9/20 0020.
 */

operateFormatter = function () {
    return [
        '<a class="show" href="javascript:void(0)">修改信息</a>'
    ].join('');
};

window.operateEvents = {
    'click .show': function (e, value, row) {
        if (row.id == 6) {
            showModel("showNoticeDetail-div", function () {
                $("#ids").val(row.id);
                $("#names").val(row.name);
                $("#value").val(row.value)
            })
        }else {
            showModel("showDetail-div", function () {
                $("#content").hide();
                $("#id").val(row.id);
                $("#name").val(row.name);
                editor.setContent(row.value);
            })
        }
    }
};

/**
 * 表单提交
 */
bindClick("button[data-event=submit-updateInfo]", function () {

    var content = UE.getEditor('editor').getContent();
    $("#content").val(content);

    var form = $("#htmlFrom");
    var param = form.formToArray();

    $.post($().AbsUrlParse("/web/html/update"), param, function (data) {
        if (data.res.code == 40000) {
            hint("处理成功");
            closeModel('showDetail-div');
            var table = $("#table");
            table.bootstrapTable("refresh");
        } else {
            hint(data.res.msg);
        }
    });
});

/**
 * 表单提交
 */
bindClick("button[data-event=submit-updateValueInfo]", function () {

    var form = $("#htmlValueFrom");
    var param = form.formToArray();

    $.post($().AbsUrlParse("/web/html/update"), param, function (data) {
        if (data.res.code == 40000) {
            hint("处理成功");
            closeModel('showNoticeDetail-div');
            var table = $("#table");
            table.bootstrapTable("refresh");
        } else {
            hint(data.res.msg);
        }
    });
});